/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package control;

import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 *
 * @author fred
 */
public class Connection {
    
    private java.sql.Connection con;

    public Connection() throws ClassNotFoundException, SQLException {
        Class.forName("com.mysql.jdbc.Driver");
        con = DriverManager.getConnection("jdbc:mysql://localhost:3306/twitter",
                "twitter-pc2", "123456");
    }

    public void command(String comando) throws SQLException {
        Statement stm = con.createStatement();
        stm.executeUpdate(comando);
        stm.close();
    }

    public ResultSet query(String comando) throws SQLException {
        Statement stm = con.createStatement();
        return stm.executeQuery(comando);
    }
    
}
